package com.cloudsigns.factorymanager2.produce.presenter.produce_team;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.produce_team.ISendHandOverOrderView;
import com.cloudsigns.factorymanager2.produce.model.produce_team.ISendHandOverOrderModel;
import com.cloudsigns.factorymanager2.produce.model.produce_team.SendHandOverOrderModel;

/**
 * 提交工序交接单
 */
public class SendHandOverOrderPresenter {
    private ISendHandOverOrderView view;
    private ISendHandOverOrderModel model;
    private Handler handler = new Handler();

    public SendHandOverOrderPresenter(ISendHandOverOrderView view) {
        this.view = view;
        this.model = new SendHandOverOrderModel();
    }

    public void sendHandOverOrder() {
        model.sendHandOverOrder(view.getAmount(), view.getContent(), view.imgUrlList(), view.getOrderId(), view.getProductId(), view.getWorkPartId(), view.getWorkPartOrderId(), new SendHandOverOrderModel.OnSendHandOverOrderListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getSendHandOverOrderSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getSendHandOverOrderFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
